<template>
    <Layout>
        <Sider hide-trigger :style="{height: screenHeight+'px',overflow:'auto',backgroundColor:'#ffffff'}">
            <hig-nav :syscode="userType" :nav-list="navList"></hig-nav>
        </Sider>
        <Layout :style="{padding: '0 24px 24px'}">
            <router-view></router-view>
        </Layout>
    </Layout>
</template>
<script>
import bus from '@/bus'
import HigNav from '@/component/HigNav.vue'
import {trees} from '@/store/tree'
export default {
    data() {
        return {
            contentShow:true,
            userType:-1,
            screenHeight: 0,
            navList:[]
        }
    },
    components: {
        HigNav
    },
    methods: {
        menuInit(){
            let myTrees = this.$store.getTree() ? this.$store.getTree() : trees
            myTrees.forEach(element => {
                if(element.userType.includes(this.$store.getUser('userType'))) {
                    this.navList = element.trees
                }
            })

            //打开默认首页
            console.log('trees=',this.navList[0].child[0])
            this.$router.push({
                name: this.navList[0].child[0].name
            })
        }
    },
    mounted(){
        // 可视窗口高度（不包含滚动条）
        this.screenHeight = document.documentElement.clientHeight - 64
        // 监听窗口变化
        window.addEventListener('resize', () => {
            this.screenHeight = document.documentElement.clientHeight - 64
        })
    },
    created(){
        this.menuInit()
    }
}
</script>
<style scoped>

</style>